package com.lms.common.file.controller;

import com.lms.common.entity.TLmsFile;
import com.lms.common.file.service.ITLmsFileService;
import com.lms.common.web.controller.BaseController;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
public class FileController extends BaseController<ITLmsFileService, TLmsFile> {

    @PostMapping("/upload")
    public String upload(@RequestPart("file") MultipartFile uploadFile,
                         @RequestParam("businessId") String businessId,
                         @RequestParam("businessType") String businessType,
                         @RequestParam("businessColumn") String businessColumn) {
        return this.baseService.update(uploadFile, businessId, businessType, businessColumn);
    }

    @GetMapping("/download")
    public void download(HttpServletResponse response) {
        this.baseService.download(response, "a");
    }
}
